package com.ruoyi.informfrontend.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.informfrontend.mapper.CloudClassroomProjectMainMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.informfrontend.domain.CloudClassroom;
import com.ruoyi.informfrontend.service.ICloudClassroomService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 云课堂列表Controller
 *
 * @author ruoyi
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/classroom")
public class CloudClassroomController extends BaseController
{
    @Autowired
    private ICloudClassroomService cloudClassroomService;

    @Autowired
    private CloudClassroomProjectMainMapper cloudClassroomProjectMainMapper;
    /**
     * 查询云课堂列表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CloudClassroom cloudClassroom)
    {
        startPage();
        if (cloudClassroom.getProjectId()!=null){
            cloudClassroomProjectMainMapper.updateNum(cloudClassroom.getProjectId());
        }
        List<CloudClassroom> list = cloudClassroomService.selectCloudClassroomList(cloudClassroom);
        return getDataTable(list);
    }

    /**
     * 查询云课堂列表列表
     */
    @GetMapping("/app")
    public AjaxResult app(CloudClassroom cloudClassroom)
    {
        startPage();
        if (cloudClassroom.getProjectId()!=null){
            cloudClassroomProjectMainMapper.updateNum(cloudClassroom.getProjectId());
        }
        List<CloudClassroom> list = cloudClassroomService.selectCloudClassroomList(cloudClassroom);
        return success(list);
    }

    /**
     * 获取云课堂列表详细信息
     */
    @GetMapping(value = "/getOne")
    public AjaxResult getInfo(@RequestParam("id") Long id)
    {
        return success(cloudClassroomService.selectCloudClassroomById(id));
    }

    /**
     * 新增云课堂列表
     */
    @PostMapping
    public AjaxResult add(@RequestBody CloudClassroom cloudClassroom)
    {
        return toAjax(cloudClassroomService.insertCloudClassroom(cloudClassroom));
    }

    /**
     * 修改云课堂列表
     */
    @PutMapping
    public AjaxResult edit(@RequestBody CloudClassroom cloudClassroom)
    {
        return toAjax(cloudClassroomService.updateCloudClassroom(cloudClassroom));
    }

    /**
     * 删除云课堂列表
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cloudClassroomService.deleteCloudClassroomByIds(ids));
    }
}
